home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / TEXTCNT.ICN < prev    next >
Text File  |  1992-09-28  |  1KB  |  48 lines

  1. ############################################################################
  2. #
  3. #    File:     textcnt.icn
  4. #
  5. #    Subject:  Program to tabulate properties of text file
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     December 27, 1989
  10. #
  11. ###########################################################################
  12. #
  13. #     This program tabulates the number of characters, "words", and
  14. #  lines in standard input and gives the maxium and minimum line length.
  15. #  
  16. ############################################################################
  17.  
  18. procedure main()
  19.    local chars, words, lines, name, infile, max, min, line
  20.  
  21.    chars := words := lines := 0
  22.    max := 0
  23.    min := 2 ^ 30            # larger than possible line length
  24.    
  25.      while line := read(infile) do {
  26.         max <:= *line
  27.         min >:= *line
  28.         lines +:= 1
  29.         chars +:= *line + 1
  30.         line ? while tab(upto(&letters)) do {
  31.            words +:= 1
  32.            tab(many(&letters))
  33.            }
  34.         }
  35.    
  36.      if min = 2 ^ 30 then
  37.         write("empty file")
  38.      else {
  39.         write("number of lines:     ",right(lines,8))
  40.         write("number of words:     ",right(words,8))
  41.         write("number of characters:",right(chars,8))
  42.         write()
  43.         write("longest line:        ",right(max,8))
  44.         write("shortest line:       ",right(min,8))
  45.         }
  46.  
  47. end
  48.